<?php namespace App\Providers;

use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Request;

class RouteServiceProvider extends ServiceProvider {

	/**
	 * This namespace is applied to the controller routes in your routes file.
	 *
	 * In addition, it is set as the URL generator's root namespace.
	 *
	 * @var string
	 */
	protected $namespace = 'App\Http\Controllers';

	/**
	 * Define your route model bindings, pattern filters, etc.
	 *
	 * @param  \Illuminate\Routing\Router  $router
	 * @return void
	 */
	public function boot(Router $router)
	{
		parent::boot($router);

        $router->pattern('id', '[0-9]+');
        $router->pattern('width', '[0-9]+');
        $router->pattern('height', '[0-9]+');

        $router->pattern('segment_id', '[0-9]+');
        $router->pattern('goods_package_id', '[0-9]+');
        $router->pattern('bedroom_count', '[0-9]+');
        $router->pattern('area_id', '[0-9]+');
        $router->pattern('alias', '[A-Za-z0-9]+');

		//
	}

	/**
	 * Define the routes for the application.
	 *
	 * @param  \Illuminate\Routing\Router  $router
	 * @return void
	 */
	public function map(Router $router)
	{
        $router->group(['namespace' => $this->namespace], function($router)
        {
            require app_path('Http/routes.php');
        });
//        $router->group([
//            'namespace' => $this->namespace
//        ], function ($router)
//        {
////            load_routes(app_path('Http/Routes/Global'));
//            $request = Request::instance();
//            $host = $request->headers->get('host');
//
//            switch ($host) {
//                case env('DOMAIN_ADMIN'):
//                    load_routes(app_path('Http/Routes/Admin'));
//                    break;
//                case env('DOMAIN_API'):
//                    load_routes(app_path('Http/Routes/Api'));
//                    break;
//                case env('DOMAIN_WAP'):
//                    load_routes(app_path('Http/Routes/Wap'));
//                default:
//                    break;
//            }
//
//        });
	}

}
